package com.ruoyi.project.remake.controller;

import java.util.List;

import com.ruoyi.project.remake.domain.TPaperCase;
import com.ruoyi.project.remake.service.ITPaperCaseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 纸质病例管理Controller
 *
 * @author 孙山伟
 * @date 2020-12-20
 */
@RestController
@RequestMapping("/remake/papercase")
public class TPaperCaseController extends BaseController
{
    @Autowired
    private ITPaperCaseService tPaperCaseService;

    /**
     * 查询纸质病例管理列表
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPaperCase tPaperCase)
    {
        startPage();
        List<TPaperCase> list = tPaperCaseService.selectTPaperCaseList(tPaperCase);
        return getDataTable(list);
    }

    /**
     * 导出纸质病例管理列表
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:export')")
    @Log(title = "纸质病例管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPaperCase tPaperCase)
    {
        List<TPaperCase> list = tPaperCaseService.selectTPaperCaseList(tPaperCase);
        ExcelUtil<TPaperCase> util = new ExcelUtil<TPaperCase>(TPaperCase.class);
        return util.exportExcel(list, "papercase");
    }

    /**
     * 获取纸质病例管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPaperCaseService.selectTPaperCaseById(id));
    }

    /**
     * 新增纸质病例管理
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:add')")
    @Log(title = "纸质病例管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPaperCase tPaperCase)
    {
        return toAjax(tPaperCaseService.insertTPaperCase(tPaperCase));
    }

    /**
     * 修改纸质病例管理
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:edit')")
    @Log(title = "纸质病例管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPaperCase tPaperCase)
    {
        return toAjax(tPaperCaseService.updateTPaperCase(tPaperCase));
    }

    /**
     * 删除纸质病例管理
     */
    @PreAuthorize("@ss.hasPermi('remake:papercase:remove')")
    @Log(title = "纸质病例管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPaperCaseService.deleteTPaperCaseByIds(ids));
    }
}
